home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / Menu Controls / BetterFeedback.h < prev    next >
Encoding:
Text File  |  1995-06-24  |  3.7 KB  |  98 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
  2. // BetterFeedback.h
  3.  
  4. /*--------------------------------------------------------------------------------------------------
  5.     This unit attempts to provide smooth flicker-free feedback during command tracking.
  6.  
  7.           T H E O R Y    O F   O P E R A T I O N
  8.  
  9.     By synchronizing drawing to the vertical retrace interrupt, this unit attempts
  10.     to improve the feedback that mouse trackers provide.
  11.  
  12.     Ideally, this behavior would be part of MacApp's TApplication.TrackMouse method.
  13.     What TApplication.TrackMouse should really do is:
  14.         a) wait for the vertical retrace interrupt of the device that the view most intersects
  15.         b) erase the old tracker feedback by calling tracker.TrackFeedback(…, turn It Off, …)
  16.         c) immediately draw the new feedback by calling tracker.TrackFeedback(…, turn It on, …)
  17.  
  18.     However, with the current architecture, this is impossible. TApplication.TrackMouse currently
  19.     does the following:
  20.         a) call tracker.TrackFeedback(…, turn It Off, …) to erase the previous tracker feedback
  21.         b) call tracker.TrackMouse(trackMove, …) to tell the tracker the track phase
  22.         c) call tracker.TrackFeedback(…, turn It On, …) to draw the new tracker feedback
  23.  
  24.     UBetterFeedbackCmd provides a way to work within the current architecture to provide a close
  25.     attempt at smooth flicker-free feedback. To take advantage of this unit, create a
  26.     subclass of TBetterFeedbackCmd. Then, OVERRIDE TBetterFeedbackCmd::TrackFeedback()
  27.     and as the first statement of this method call:
  28.             Inherited::TrackFeedback(anchorPoint, nextPoint, turnItOn, mouseDidMove);
  29.     so that TBetterFeedbackCmd::TrackFeedback can synch to the vertical retrace interrupt.
  30.     Then the tracker should go ahead and draw/erase the feedback.
  31.  
  32.     For an example, see ShapeCommands: TShapeSketcher, TShapeDragger, and TShapeSelector.
  33. --------------------------------------------------------------------------------------------------*/
  34.  
  35. #ifndef __BETTERFEEDBACK__
  36. #define __BETTERFEEDBACK__
  37.  
  38.  
  39. #ifndef __UCOMMAND__
  40. #include <UCommand.h>
  41. #endif
  42.  
  43. #ifndef __UCOMMANDHANDLER__
  44. #include <UCommandHandler.h>
  45. #endif
  46.  
  47. //--------------------------------------------------------------------------------------------------
  48. // Constants
  49.  
  50. const Boolean kInstall = true;                    // pass to BetterFeedback: install our VBL?
  51. const Boolean kBetterFeedbackDesired = true;    // pass to IBetterFeedbackCmd: desire better feedback?
  52.  
  53. //--------------------------------------------------------------------------------------------------
  54. // CLASS TBetterFeedbackCmd - common ancestor for all commands operating on one or more shapes
  55. //--------------------------------------------------------------------------------------------------
  56. class TBetterFeedbackCmd : public TTracker
  57. {
  58.     MA_DECLARE_CLASS;
  59.  
  60.   public:
  61.     TBetterFeedbackCmd();        // Constructor
  62.     void IBetterFeedbackCmd(CommandNumber itsCommandNumber,
  63.                              TCommandHandler* itsContext,
  64.                             Boolean canUndo,
  65.                             Boolean causesChange,
  66.                             TObject* objectToNotify,
  67.                             TView* itsView,
  68.                             TScroller* itsScroller,
  69.                             VPoint itsMouse,
  70.                             Boolean betterFeedbackDesired);
  71.  
  72.     virtual void Free();    // Override
  73.  
  74.     // • for tracking
  75.     void BetterFeedback(Boolean install);
  76.     void WaitBetterFeedback();
  77.  
  78.     virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
  79.                                  VPoint& anchorPoint,
  80.                                  VPoint& previousPoint,
  81.                                  VPoint& nextPoint,
  82.                                  Boolean mouseDidMove);    // Override
  83.  
  84.     virtual void TrackFeedback(TrackPhase aTrackPhase,
  85.                                 const VPoint& anchorPoint,
  86.                                 const VPoint& previousPoint,
  87.                                 const VPoint& nextPoint,
  88.                                 Boolean mouseDidMove,
  89.                                 Boolean turnItOn);    // Override
  90.  
  91.   protected:
  92.     Boolean    fBetterFeedbackInstalled;        // are the synchronization routines in?
  93.     Boolean    fBetterFeedbackDesired;            // want the synchronization routines?
  94. };
  95.  
  96.  
  97. #endif
  98.